package com.itheima.stock.config;

import com.itheima.stock.service.StockTimerTaskServer;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


import java.util.Date;

@Component
@Slf4j
public class Task {
    @Autowired
    private StockTimerTaskServer stockTimerTaskServer;

    //再xxljob中配置调度时间
    @XxlJob("demoJobHandler")
    //@XxlJob(value = "SyncUserJob")
    //spring自带的演示任务调度
//    @Scheduled(cron = "0/5 * *  * * ? ")   //每5秒执行一次
    public void execute() {
        log.info("获取大盘数据，时间：{}", new Date());
        stockTimerTaskServer.getInnerMarkInfo();
    }

    @XxlJob("getStockRtIndex")
    public void getStockRtIndex(){
        log.info("获取分钟级个股数据:{}",new Date());
        //xxljob对半小时不能处理可在代码中判断是否大于9：30
        stockTimerTaskServer.getStockRtIndex();
    }
}
